package com.teamwork.module03.controller;


import com.teamwork.common.result.Result;
import com.teamwork.common.util.FileUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController("user2controller")
@RequestMapping("/api/user/icon")
public class UserIconController {

    @Value("${user.icon}")
    private String basePath;

    @GetMapping("/{name}")
    public void downloadImg(@PathVariable("name")String name, HttpServletRequest req, HttpServletResponse res){
        System.out.println(name);
        FileUtils.downloadFile(basePath,name,req,res);

    }

}
